//
//  photoHeaderView.m
//  YuErmuYing
//
//  Created by Tiancheng on 16/8/25.
//  Copyright © 2016年 Tiancheng. All rights reserved.
//

#import "photoHeaderView.h"
#import "UIImageView+WebCache.h"

@implementation photoHeaderView

-(void)setPhoto:(postPhoto *)photo
{
    _photo=photo;
    NSURL* imagePath = [NSURL URLWithString:photo.picString];
    //给一张默认图片，先使用默认图片，当图片加载完成后再替换
    [self.picImageView sd_setImageWithURL:imagePath placeholderImage:[UIImage imageNamed:@"default"]];
    self.nameLabel.text=photo.nameString;
    self.contentLabel.text=photo.contentString;
    self.timeLabel.text=photo.timeString;
    self.starImageView01.image=[UIImage imageNamed:@"star-click"];
    self.starImageView02.image=[UIImage imageNamed:@"star-click"];
    self.starImageView03.image=[UIImage imageNamed:@"star-click"];
    self.starImageView04.image=[UIImage imageNamed:@"star-click"];
    self.line01.backgroundColor=[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0];
    self.line02.backgroundColor=[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0];
    self.line03.backgroundColor=[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0];
}
+(id)shardeManager;
{
    static photoHeaderView*singleton=nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        singleton = [self photoView];
    });
    return singleton;
}
+(instancetype) photoView
{
    
    NSBundle *bundle=[NSBundle mainBundle];
    NSArray *objs=[bundle loadNibNamed:@"photoHeaderView" owner:nil options:nil];
    return [objs lastObject];
}

+(instancetype) appViewWithApp:(postPhoto *)pp
{
    //photoHeaderView *pHeaderView=[self photoView];
    photoHeaderView *pHeaderView=[self shardeManager];
    pHeaderView.photo=pp;
    return pHeaderView;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
